﻿using System;
using System.Data;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using QzEbook.AccessObject;
using QzEbook.Common;

public partial class module_userInfo : System.Web.UI.UserControl
{
    private StringBuilder sb=null;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            bindData();
        }
    }

    private void bindData()
    {
        string uid=Request["UID"];
        if (String.IsNullOrEmpty(uid))
        {
            return;
        }

        
        SiteUser userInfo = new SiteUser();
        userInfo.Uid = int.Parse(uid);
        userInfo=userInfo.select();
        this.Page.Title = string.Format("{0} 杂志主页",userInfo.Name);

        sb = new StringBuilder();
        sb.AppendLine("<ul id=\"userinfo\">");
        sb.AppendLine("<li>");
        sb.AppendLine("<h3>用户信息</h3>");
        sb.AppendLine("<dl>");
        sb.AppendFormat("<dt><a href=\"addFriend.xhtml?Uid={2}\" title=\"加{1}为好友\"><img src=\"{0}\" alt='点击加为好友'/></a></dt>", Config.UserBookSavePath + "noset.gif",userInfo.Name,userInfo.Uid);
        sb.AppendFormat("<dt><a href=\"window/index.xhtml?Uid={0}\">进入{1}个人主页</a></dt>", uid,userInfo.Name);
        sb.AppendFormat("<dt>用户等级:</dt><dd>{0}</dd>", userInfo.LevelName);
        sb.AppendFormat("<dt>注册时间:</dt><dd>{0}</dd>", userInfo.Date.ToString("yyyy-MM-dd hh:mm:ss"));
        //sb.AppendFormat("<dt>qq:</dt><dd>{0}</dd>", userInfo.Qq);
        //sb.AppendFormat("<dt>邮箱:</dt><dd>{0}</dd>", userInfo.Mail);
        sb.AppendFormat("<dt>已有电子书:</dt><dd>{0}本</dd>", userInfo.GrossBooks);
        sb.AppendLine("</dl>");
        sb.AppendLine("</li>");

        sb.AppendLine("<li>");
        sb.AppendLine("<h3>好友列表</h3>");
        ////for (int i = 0; i < 10; i++)
        ////{
        ////    sb.AppendLine("<a>d</a>");
        ////}
        sb.AppendLine("</li>");

        sb.AppendLine("</ul>");

    }

    protected override void Render(HtmlTextWriter writer)
    {
        if (sb != null)
        {
            writer.Write(sb.ToString());
        }
        base.Render(writer);
    }
}
